
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 1
 * @Author : WangRuoyu 
 * @Date : 2023/5/12 17:19
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int main() {
    int n;
    cin >> n;
    int nums[n];
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }

    int res = 0;
    for (int i = 1; i < n - 1; ++i) {
        if ((nums[i] - nums[i - 1]) * (nums[i + 1] - nums[i]) < 0) {
            res++;
        }
    }

    cout << res;

    return 0;
}